///////////////////////////////////////////////////////////////////////////////
//	FILENAME:	ChooseEncoding.m
//	SUMMARY:	Implementation of a Tool-based UI for eText HTML Encoders
//	SUPERCLASS:	Object
//	INTERFACE:	None
//	PROTOCOLS:	<Tool>
//	AUTHOR:		Rohit Khare
//	COPYRIGHT:	(c) 1994 California Institure of Technology, eText Project
///////////////////////////////////////////////////////////////////////////////
//	DESCRIPTION: This is a custom class designed to provide a UI for a 
//	UI-less hook of eText: allowing the user to choose between different
//	encoding tables for HTML character mappping.
///////////////////////////////////////////////////////////////////////////////
//	HISTORY
//	10/31/94:	Created. Implemented in just minutes, from scratch.
///////////////////////////////////////////////////////////////////////////////

#import "ChooseEncoding.h"

@implementation ChooseEncoding

+ new 
{
	static ChooseEncoding *ce = nil;
	
	if (!ce) {
		ce = [[ChooseEncoding alloc] init];
	}
	return ce;
}

+ toolAwake:theApp
{
	[theApp registerAccessory:NXUniqueString("Choose HTML Encoding")
				key:'\0'
			   name:NXUniqueString("ChooseEncoding")
			 target:[ChooseEncoding new]
			 action:@selector(activate:)];
	return self;
}

- init {return [super init];}

- free {return self;}

- activate:sender
{
	int choice = NXRunAlertPanel("Choose Encoding...","You can optimize the HTML generated to work around particular clients. To permanently change your default encoding, \"dwrite eText HTMLEncoding Type\" (look in the app wrapper).", "Strict HTML","ASCII","OmniWeb");
	switch (choice) {
		case NX_ALERTDEFAULT: NXSetDefault([NXApp appName], "HTMLEncoding", "WebStep"); break;
		case NX_ALERTALTERNATE: NXSetDefault([NXApp appName], "HTMLEncoding", "ASCII"); break;
		case NX_ALERTOTHER: NXSetDefault([NXApp appName], "HTMLEncoding", "OmniWeb"); break;
	}
	[eText flushHTMLEncoding]; // yeah, it's a memory leak. so f*cking sue me.
	return self;
}

@end